/*
 * @Description  :
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2021-12-03 11:10:14
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-03-24 19:35:52
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\supply-management\\services\\supply-management.service.ts
 * Copyright (C) 2022 huzhenhong. All rights reserved.
 */
import { Injectable, Injector } from '@angular/core';
import { map } from 'rxjs/operators';
import { BaseService } from 'src/app/shared/services';

@Injectable({
  providedIn: 'root'
})
export class SupplyManagementService extends BaseService {
  $api_get_enterprise_project = `/api/mdc/cuc/enterpriseProject/getEnterpriseProjectList `; // 所属项目列表
  // 取消货源
  $api_cancle_goods_source = `/api/sdc/goodsResourceOperate/cancelSource`;
  // 整车获取货源表详情
  $api_get_getCompleteVehicleDetail = `/api/sdc/goodsResourceOperate/getWholeDetail`;
  // 大宗获取货源表详情
  $api_get_getBulkDetail = `/api/sdc/goodsResourceOperate/getBulkDetail`;
  // 查询运营后台大宗货源列表
  $api_get_bulkPage_list = `/api/sdc/goodsResourceOperate/listBulkPage`;
  // 查询运营后台整车货源列表
  $api_get_wholePage_list = `/api/sdc/goodsResourceOperate/listWholePage`;
  // 整车再下一单
  $api_set_saveAnotherWholeOrder = `/api/sdc/goodsResourceOperate/saveAnotherWholeOrder`;
  // 大宗再下一单
  $api_set_saveAnotherBulkOrder = `/api/sdc/goodsResourceOperate/saveAnotherBulkOrder`;
  // 编辑整车货源
  $api_set_WholeModify = `/api/sdc/goodsResourceOperate/updateWhole`;
  // 编辑大宗货源
  $api_set_bulkModify = `/api/sdc/goodsResourceOperate/updateBulk`;
  // 删除装卸货信息
  $api_delete_Wholedeletebatch = `/api/sdc/unLoadingPlace/deletebatch`;
  // 删除货物信息
  $api_delete_bulkdeletebatch = `/api/sdc/goodsInfo/deletebatch`;
  $api_get_catalogue_member = `/user?_allow_anonymous=true`;
  $api_get_listModifyPrice = `/api/sdc/goodsInfo/listModifyPrice`;
  $api_update_price = `/api/sdc/goodsResourceShipper/modifyPrice`; // 根据货物ID修改单价
  $api_get_goods_resource_statistical = `/api/sdc/goodsResourceOperate/statisticalStatus`; // 统计整车、大宗货源状态数量
  // 获取货主企业列表
  public $api_getList = '/api/mdc/cuc/enterpriseInfo/cargoOwner/getList?_allow_anonymous=true';
  public $api_commonAddress = '/api/sdc/commonAddress/list/page';
  // 获取货主企业列表
  public $api_enterpriceList = '/api/mdc/cuc/enterpriseInfo/operate/enterpriceList';
  // 取消货源
  public $api_cancelSource = '/api/sdc/goodsResourceOperate/cancelSource';
  // 整车计算附加费
  $api_getCalculatedSurcharge = `/api/sdc/expense/getCalculatedSurcharge`;
  // 整车计算附加费率
  $api_getcalculatedServiceRate = `/api/sdc/expense/getAdditionalRate`;
  // 整车计算附加费率
  $api_getAdditionalRate = `/api/sdc/expense/getAdditionalRate`;
  // 代发整车货源
  $api_consignWhole = `/api/sdc/goodsResourceOperate/consignWhole`;
  // 代发大宗货源
  $api_consignBulk = `/api/sdc/goodsResourceOperate/consignBulk`;

  $api_get_practice_car_list = `/api/mdc/cuc/enterpriseVehicle/getPracticeCarList`; // 获取熟车列表
  $api_add_car_caption = `/api/mdc/userDriverExpand/addCarCaptainForShiper`; // 设置为车队长
  $api_get_goods_resource_shipper = `/api/sdc/goodsResourceShipper/modifyPricePre`; // 修改单价页面根据货源ID获取货物表
  $api_get_car_captain_by_mobile = `/api/mdc/userDriverExpand/getCarCaptainByMobile`; // 查询车队长或者司机列表
  $api_save_assign_vehicle = `/api/sdc/goodsResourceShipper/reAssignWhole`; // 整车货源重新指派

  $api_save_assign_bulk = `/api/sdc/goodsResourceShipper/reAssignBulk`; // 货主端大宗货源指派熟车
  // 整车再下一单指派熟车
  $api_save_assign_whole = `/api/sdc/goodsResourceOperate/saveAnotherWholeOrderAssign`;
  // 代发整车货源指派熟车
  $api_save_consignWholeAssign = `/api/sdc/goodsResourceOperate/consignWholeAssign`;
  // 货主端大宗货源指派熟车
  $api_save_bulk_assign = `/api/sdc/goodsResourceOperate/saveAnotherBulkOrderAssign`;
  // 代发大宗货源指派熟车
  $api_save_consignBulkAssign = `/api/sdc/goodsResourceOperate/consignBulkAssign`;

  $api_get_has_assigned_car_list = `/api/sdc/goodsResourceShipper/getCarDriverIdsByResourceId`; // 大宗货源根据货源id获取司机和车辆的id集合

  // 根据手机号查询车队长/司机
  $api_getCarCaptainByMobile = `/api/mdc/userDriverExpand/getCarCaptainByMobile`;
  // 新增熟车
  $api_enterpriseVehicleSave = `/api/mdc/cuc/enterpriseVehicle/save`;
  // 删除熟车
  $api_deletebatch = `/api/mdc/cuc/enterpriseVehicle/deletebatch`;
  // 熟车详情
  $api_getMyDriverUserDetail = `/api/mdc/cuc/enterpriseVehicle/getMyDriverUserDetail`;

  // 获取指派熟车列表
  $api_getList_card = '/api/mdc/cuc/enterpriseVehicle/getPracticeCarList';

  // 根据地区code查询列表
  $api_getRegionByCode = '/api/mdc/pbc/region/getRegionByCode';
  // 识别身份证
  $api_checkIdCard = '/api/mdc/pbc/hwc/ocr/recognizeIdCard';
  // 驾驶证识别
  $api_recognizeDriverLicense = `/api/mdc/pbc/hwc/ocr/recognizeDriverLicense`;
  // 查询系统配置项
  public $api_get_config_item_page = '/api/mdc/pbc/sysConfigItem/list/page';

  // 货源审核
  public $api_goodsResourceAudit = '/api/sdc/goodsResourceOperate/goodsResourceAudit';
  // 货源审核【批量】
  public $api_batchGoodsResourceAudit = '/api/sdc/goodsResourceOperate/batchGoodsResourceAudit';

  // 大宗再下一单二维码
  $api_saveAnotherBulkOrderQRCode = '/api/sdc/goodsResourceOperate/saveAnotherBulkOrderQRCode';
  // 代发大宗货源二维码
  $api_consignBulkQRCode = '/api/sdc/goodsResourceOperate/consignBulkQRCode';
  // 获取操作日志列表
  public $api_getOperationLogRecordsList = '/api/mdc/pbc/operationLogRecords/getOperationLogRecordsList';
  // 获取数据字典
  $api_getDictValue = `/api/mdc/pbc/dictItems/getDictValue`;
  // 获取协议信息
  public $api_getAgreementInfoByType = '/api/mdc/pbc/agreementInfo/getAgreementInfoByType';
  // 获取协议信息
  public $api_getContractContent = '/api/sdc/contractTemplate/getContractContent';
  // 获取运价
  public $api_getFreight = '/api/mdc/cuc/freightConfig/getFreight';
  // 从业资格证
  $api_recognizeQualificationCertificate = '/api/mdc/pbc/hwc/ocr/recognizeQualificationCertificate';
  /**
   * 获取车型、车长字典数据
   * @returns
   */
  getDictOptions(params = {}) {
    return this.request(this.$api_getDictValue, params).pipe(
      map((res: any) => {
        if (!res) {
          return [];
        }
        const obj = [];
        obj.push({ label: '不限', value: '999' });
        return [...obj, ...res];
      })
    );
  }
  constructor(public injector: Injector) {
    super(injector);
  }
  public limitKeys = {
    weight: 'sys.config.goods.approvalCarMaxWeight', //整车-核载重量上限
    volume: 'sys.config.goods.approvalCarMaxVolume', //整车-核载体积上限
    piece: 'sys.config.goods.approvalCarMaxPiece', //整车-核载件数上限
    maxDays: 'sys.config.goods.wholeLoadingMaxDays', //整车-计划装货时间上限
    intervalDays: 'sys.config.goods.wholeUnloadingIntervalDays', //计划装、卸货时间间隔
    maxTimes: 'sys.config.goods.wholeLoadingMaxTimes' //整车-多装多卸地点上限
  };
  public limitKeys2 = {
    month: 'sys.config.goods.bulkEndMaxMonth', //大宗-截止时间上限
    weight: 'sys.config.goods.bulkMaxWeight', //大宗-重量上限
    volume: 'sys.config.goods.bulkMaxVolume', //大宗-体积上限
    trainNumber: 'sys.config.goods.bulkMaxTrainNumber', //大宗-车次上限
    freight: 'sys.config.goods.bulkMaxUnitFreight' //大宗-运费单价上限
  };
  // 根据ItemKey获取项值
  public $api_findItemValueByItemKeys = '/api/mdc/pbc/sysConfigItem/findItemValueByItemKeys';
  // 获取保价费信息
  public $api_getWholeInsuranceInfo = '/api/sdc/goodsResourceShipper/getWholeInsuranceInfo';
  // 下载导入货源模板-运营后台
  public $api_exportGoodsResourceOperateTemplate = '/api/sdc/uploadGoodsResource/exportGoodsResourceOperateTemplate';
  // 导入货源-运营后台
  public $api_goodsResourceOperateImport = '/api/sdc/uploadGoodsResource/goodsResourceOperateImport';
  // 下载失败数据-运营后台
  public $api_getFailUploadGoodsOperateResource = '/api/sdc/uploadGoodsResource/getFailUploadGoodsOperateResource';
  // 根据货主ID查询网络货运人信息
  public $api_getNetworkTransporter = '/api/mdc/cuc/enterpriseInfo/operate/getNetworkTransporter';
  $api_verify_vehicle_status = `/api/sdc/goodsResourceShipper/saveVerify`; // 发布货源校验司机/车队长的状态
  $api_get_sys_config = `/api/mdc/pbc/sysConfigItem/findConfigValues`; // 根据项key、业务id获取配置信息
  // 获取指派熟车列表
  $api_getListCars = '/api/mdc/cuc/enterpriseVehicle/getPracticeCarList';
  // 异步导出运营后台大宗货源列表
  $api_asyncExportBulkList = '/api/sdc/goodsResourceOperate/asyncExportBulkList';
  // 异步导出运营后台整车货源列表
  $api_asyncExportWholeList = '/api/sdc/goodsResourceOperate/asyncExportWholeList';
  // 根据货主ID查询合同签署属性
  public $api_getContractAtr = '/api/mdc/cuc/enterpriseInfo/cargoOwner/getContractAtr';
  // 发送邀请司机短信
  $api_send_msg_code = `/api/mdc/pbc/smsSend/sendInviteDriver`;

  // 校验货物名称是否合规
  $api_checkGoodsName = '/api/sdc/goodsResourceShipper/checkGoodsName';

  getDictByKey(dictKey: string) {
    const params = { dictKey: dictKey };
    return this.request(this.$api_getDictValue, params);
  }
}
